package com.kaifamiao.month04.day08;

public class Demo02 {

    public static int stringNoRepeat(String str) {
        for (int i = 0; i < str.length(); i++) {
            int index = str.indexOf(str.charAt(i));
            int lastIndex = str.lastIndexOf(str.charAt(i));
            if (index != lastIndex) {
                int num1 = stringNoRepeat(str.substring(index, lastIndex));
                int num2 = stringNoRepeat(str.substring(index + 1));
                return Math.max(num1, num2);
            }
        }
        return str.length();
    }

    public static void main(String[] args) {
        String s = "abcdadef";
        System.out.println(stringNoRepeat(s));
    }
}
